package com.lzxuni.modules.weather.service.impl;

import com.lzxuni.common.utils.HumpUtils;
import com.lzxuni.modules.common.entity.PageParameter;
import com.lzxuni.modules.weather.entity.WeatherLimit;
import com.lzxuni.modules.weather.mapper.WeatherLimitMapper;
import com.lzxuni.modules.weather.service.WeatherLimitService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
import com.lzxuni.common.utils.StringUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * <p>
 * 天气信息_天气管理_临界值 服务实现类
 * </p>
 *
 * @author LaoNa
 * @since 2020-12-01
 */
@Service
public class WeatherLimitServiceImpl extends ServiceImpl<WeatherLimitMapper, WeatherLimit> implements WeatherLimitService {

        @Override
        public PageInfo<WeatherLimit> queryPage(PageParameter pageParameter, WeatherLimit weatherLimit) {
            if (StringUtils.isNotEmpty(pageParameter.getSidx())) {
                PageHelper.startPage(pageParameter.getPage(), pageParameter.getRows()).setOrderBy(
                        HumpUtils.humpToLine(pageParameter.getSidx()) + " " + pageParameter.getSord());
            } else {
                PageHelper.startPage(pageParameter.getPage(), pageParameter.getRows());
            }
            List<WeatherLimit> weatherLimitList = baseMapper.queryList(weatherLimit);
            PageInfo<WeatherLimit> pageInfo = new PageInfo<>(weatherLimitList);
            return pageInfo;
        }

        @Override
        public List<WeatherLimit> queryList(WeatherLimit weatherLimit) {
            List<WeatherLimit> weatherLimitList = baseMapper.queryList(weatherLimit);
            return weatherLimitList;
        }

}
